package com.chengjj.kings.core.beetl;

import com.chengjj.kings.core.util.KaptchaUtil;
import com.chengjj.kings.core.util.ToolUtil;
import com.chengjj.kings.core.common.constant.Const;
import org.beetl.ext.spring.BeetlGroupUtilConfiguration;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: 成俊杰
 * @CreateDate: 2019/3/12
 * @Version: 1.0
 * @Description: beetl 扩展配置，绑定一些工具类，方便在模板中直接调用
 */
public class BeetlConfiguration extends BeetlGroupUtilConfiguration {


    @Override
    protected void initOther() {
        //全局共享变量
        Map<String, Object> shared = new HashMap<>();
        shared.put("systemName", Const.DEFAULT_SYSTEM_NAME);
        shared.put("welcomeTip", Const.DEFAULT_WELCOME_TIP);
        groupTemplate.setSharedVars(shared);
        //全局共享方法
        groupTemplate.registerFunctionPackage("shiro",new ShiroExt());
        groupTemplate.registerFunctionPackage("tool",new ToolUtil());
        groupTemplate.registerFunctionPackage("kaptcha",new KaptchaUtil());
    }
}
